package com.ruanjian2001.util;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * 测试jdbc类
 */
public class TestJDBC {
    public static void main(String[] args) {

        Connection conn = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;

        try {
            conn = JDBCUtil.getConnection();

            String sql = "update user set username = ? where id = 5";
            stmt = conn.prepareStatement(sql);

            stmt.setString(1,"aaaaaa");

            int result = stmt.executeUpdate();
            if(result == 1){
                System.out.println("执行成功");
            }else{
                System.out.println("执行失败");
            }

        }catch(Exception e){
            e.printStackTrace();
        }finally{
            JDBCUtil.close(conn,stmt,rs);
        }
    }
}
